#if !defined(_CACC_)
#define _CACC_

#pragma once
#include <oleacc.h>
#include <OBJBASE.H>
//#pragma comment( lib, "Oleacc.lib")
/**
 * This class will implement our accessible proxy object
 * that handles moving data back and forth between MSAA
 * clients.
 */
class CMSAATestView;
class MSAAPage;
class CFX_DockContainer;
class CFX_TabPage;

class CBaseProxyObject : public IAccessible 
{
public:
	static		IAccessible* CreateAccDocumentObject(CMSAATestView * pPreview);
	static		IAccessible* CreateAccPageObject(MSAAPage * pPage);
	static		IAccessible* CreateAccPageTextObject(MSAAPage * pPage);

public:
    CBaseProxyObject(){m_nRefCount = 0;};
    virtual ~CBaseProxyObject(){};


    // Implement IUnknown
    virtual STDMETHODIMP QueryInterface(REFIID riid, void** ppvObject);
    virtual STDMETHODIMP_(ULONG) AddRef();
    virtual STDMETHODIMP_(ULONG) Release();

	virtual STDMETHODIMP get_accHelp(VARIANT varChild, BSTR *pszHelp);
    virtual STDMETHODIMP get_accHelpTopic(BSTR *pszHelpFile, VARIANT varChild,long *pidTopic);

    // Implement IDispatch
    virtual STDMETHODIMP GetTypeInfoCount(unsigned int FAR* pctinfo);
    virtual STDMETHODIMP GetTypeInfo(unsigned int iTInfo, LCID lcid, ITypeInfo FAR* FAR* ppTInfo);
    virtual STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgDispId);
    virtual STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR* pDispParams, 
                        VARIANT FAR* pVarResult, EXCEPINFO FAR* pExcepInfo, unsigned int FAR* puArgErr);

protected:
    long               m_nRefCount;
};


class CAccDocumentProxyObject : public CBaseProxyObject
{

public:
    CAccDocumentProxyObject(CMSAATestView * pPreview);
    ~CAccDocumentProxyObject();

    // Implement IAccessible
    STDMETHODIMP get_accParent(IDispatch **ppdispParent);        
    STDMETHODIMP get_accChildCount(long *pcountChildren);        
    STDMETHODIMP get_accChild(VARIANT varChild, IDispatch **ppdispChild);        
    STDMETHODIMP get_accName(VARIANT varChild,BSTR *pszName);        
    STDMETHODIMP get_accValue(VARIANT varChild, BSTR *pszValue);
    STDMETHODIMP get_accDescription(VARIANT varChild, BSTR *pszDescription);
    STDMETHODIMP get_accRole(VARIANT varChild, VARIANT *pvarRole);
    STDMETHODIMP get_accState(VARIANT varChild, VARIANT *pvarState);
    STDMETHODIMP get_accKeyboardShortcut(VARIANT varChild, BSTR *pszKeyboardShortcut);
    STDMETHODIMP get_accFocus(VARIANT *pvarChild);
    STDMETHODIMP get_accSelection(VARIANT *pvarChildren);
    STDMETHODIMP get_accDefaultAction(VARIANT varChild, BSTR *pszDefaultAction);        
    STDMETHODIMP accSelect(long flagsSelect, VARIANT varChild);
    STDMETHODIMP accLocation(long *pxLeft, long *pyTop,long *pcxWidth,long *pcyHeight,VARIANT varChild);        
    STDMETHODIMP accNavigate(long navDir, VARIANT varStart, VARIANT *pvarEndUpAt);
    STDMETHODIMP accHitTest(long xLeft, long yTop,VARIANT *pvarChild);
    STDMETHODIMP accDoDefaultAction(VARIANT varChild);
    STDMETHODIMP put_accName(VARIANT varChild, BSTR szName);
    STDMETHODIMP put_accValue(VARIANT varChild, BSTR szValue);
  
    /**
     * NULLs out the data object. This should be done for cases where
     * the proxy object still has ref counts but the window is being destroyed.
     *
     * @return - none
     */
    void NullControlData()
    {
        m_pPreview = NULL;
        // END OF FUNCTION
    }
	CMSAATestView * GetControlData()
	{
		return m_pPreview;
	}
    
private:
    CMSAATestView *   m_pPreview;
	IAccessible*        m_pStdAccessibleObject; // The standard server for the HWND.
};

class CAccPageProxyObject : public CBaseProxyObject
{
public:
    CAccPageProxyObject(MSAAPage * pPage);
    ~CAccPageProxyObject();


    // Implement IAccessible
    STDMETHODIMP get_accParent(IDispatch **ppdispParent);        
    STDMETHODIMP get_accChildCount(long *pcountChildren);        
    STDMETHODIMP get_accChild(VARIANT varChild, IDispatch **ppdispChild);        
    STDMETHODIMP get_accName(VARIANT varChild,BSTR *pszName);        
    STDMETHODIMP get_accValue(VARIANT varChild, BSTR *pszValue);
    STDMETHODIMP get_accDescription(VARIANT varChild, BSTR *pszDescription);
    STDMETHODIMP get_accRole(VARIANT varChild, VARIANT *pvarRole);
    STDMETHODIMP get_accState(VARIANT varChild, VARIANT *pvarState);
    STDMETHODIMP get_accKeyboardShortcut(VARIANT varChild, BSTR *pszKeyboardShortcut);
    STDMETHODIMP get_accFocus(VARIANT *pvarChild);
    STDMETHODIMP get_accSelection(VARIANT *pvarChildren);
    STDMETHODIMP get_accDefaultAction(VARIANT varChild, BSTR *pszDefaultAction);        
    STDMETHODIMP accSelect(long flagsSelect, VARIANT varChild);
    STDMETHODIMP accLocation(long *pxLeft, long *pyTop,long *pcxWidth,long *pcyHeight,VARIANT varChild);        
    STDMETHODIMP accNavigate(long navDir, VARIANT varStart, VARIANT *pvarEndUpAt);
    STDMETHODIMP accHitTest(long xLeft, long yTop,VARIANT *pvarChild);
    STDMETHODIMP accDoDefaultAction(VARIANT varChild);
    STDMETHODIMP put_accName(VARIANT varChild, BSTR szName);
    STDMETHODIMP put_accValue(VARIANT varChild, BSTR szValue);
    
    /**
     * NULLs out the data object. This should be done for cases where
     * the proxy object still has ref counts but the window is being destroyed.
     *
     * @return - none
     */
    void NullControlData()
    {
        m_pPage = NULL;
        // END OF FUNCTION
    }
    
private:
    MSAAPage *   m_pPage;
};

class CAccPageTextProxyObject : public CBaseProxyObject
{
public:
    CAccPageTextProxyObject(MSAAPage * pPage);
    ~CAccPageTextProxyObject();


    // Implement IAccessible
    STDMETHODIMP get_accParent(IDispatch **ppdispParent);        
    STDMETHODIMP get_accChildCount(long *pcountChildren);        
    STDMETHODIMP get_accChild(VARIANT varChild, IDispatch **ppdispChild);        
    STDMETHODIMP get_accName(VARIANT varChild,BSTR *pszName);        
    STDMETHODIMP get_accValue(VARIANT varChild, BSTR *pszValue);
    STDMETHODIMP get_accDescription(VARIANT varChild, BSTR *pszDescription);
    STDMETHODIMP get_accRole(VARIANT varChild, VARIANT *pvarRole);
    STDMETHODIMP get_accState(VARIANT varChild, VARIANT *pvarState);
    STDMETHODIMP get_accKeyboardShortcut(VARIANT varChild, BSTR *pszKeyboardShortcut);
    STDMETHODIMP get_accFocus(VARIANT *pvarChild);
    STDMETHODIMP get_accSelection(VARIANT *pvarChildren);
    STDMETHODIMP get_accDefaultAction(VARIANT varChild, BSTR *pszDefaultAction);        
    STDMETHODIMP accSelect(long flagsSelect, VARIANT varChild);
    STDMETHODIMP accLocation(long *pxLeft, long *pyTop,long *pcxWidth,long *pcyHeight,VARIANT varChild);        
    STDMETHODIMP accNavigate(long navDir, VARIANT varStart, VARIANT *pvarEndUpAt);
    STDMETHODIMP accHitTest(long xLeft, long yTop,VARIANT *pvarChild);
    STDMETHODIMP accDoDefaultAction(VARIANT varChild);
    STDMETHODIMP put_accName(VARIANT varChild, BSTR szName);
    STDMETHODIMP put_accValue(VARIANT varChild, BSTR szValue);
    
    /**
     * NULLs out the data object. This should be done for cases where
     * the proxy object still has ref counts but the window is being destroyed.
     *
     * @return - none
     */
    void NullControlData()
    {
        m_pPage = NULL;
        // END OF FUNCTION
    }
    
private:
    MSAAPage *   m_pPage;
};

#endif